﻿using System;
using System.Collections.Generic;

public class Course : ICourseExam
{
    private string name;
    private HashSet<Student> studentsInCourse;

    public Course(string name)
    {
        this.name = name;
        studentsInCourse = new HashSet<Student>();
    }

    public int Count
    {
        get
        {
            return studentsInCourse.Count;
        }
    }

    public string Name
    {
        get
        {
            return name;
        }
        set
        {
            name = value;
        }
    }

    public void AddExamResult(Student student, string name, int grade)
    {
    }

    public void AddStudent(Student student)
    {
        if (studentsInCourse.Contains(student))
        {
            throw new ArgumentException("Students in course must not duplicate");
        }
        else if (this.Count == 30)
        {
            throw new OverflowException("Only up to 30 students are allowed in a course"); 
        }
        else
        {
            studentsInCourse.Add(student);
        }
    }

    public bool Contains(Student student)
    {
        bool contains = studentsInCourse.Contains(student);
        return contains;
    }

    public void DeleteStudent(Student student)
    {
        if (!studentsInCourse.Contains(student))
        {
            throw new ArgumentException(string.Format("No such student {0}", student));
        }
        else
        {
            studentsInCourse.Remove(student);
        }
    }

    public IList<int> GetExamResults(Student student)
    {
        return null;
    }
}